package com.ziyucoding.springboot.labs.lab8.skywalking.rocketmqdemo.consumer;

import com.ziyucoding.springboot.labs.lab8.skywalking.rocketmqdemo.message.DemoMessage;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 消费者
 *
 * @author ziyucoding
 * @date 2022-11-01
 **/
@Component
@RocketMQMessageListener(
        topic = DemoMessage.TOPIC,
        consumerGroup = "demo-consumer-group-" + DemoMessage.TOPIC
)
public class DemoConsumer implements RocketMQListener<DemoMessage> {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void onMessage(DemoMessage demoMessage) {
        logger.info("[onMessage][线程编号：{} 消息内容：{}]", Thread.currentThread().getId(), demoMessage);
    }
}
